CC=gcc
PREFIX?=/usr/local
CFLAGS?=-g
MAINFLAGS:=-DVERSION='"$(VERSION)"' -Wall -Wextra -Werror -Wno-unused-parameter
# LDFLAGS+=-static
INCLUDE+=-Iinclude
BINDIR?=$(PREFIX)/bin
MANDIR?=$(PREFIX)/share/man
PCDIR?=$(PREFIX)/share/pkgconfig
OUTDIR=.build

OBJECTS=\
	$(OUTDIR)/main.o \
	$(OUTDIR)/utf8_fgetch.o \
	$(OUTDIR)/utf8_size.o \
	$(OUTDIR)/utf8_decode.o

$(OUTDIR)/%.o: src/%.c
	@mkdir -p $(OUTDIR)
	$(CC) -std=c99 -pedantic -c -o $@ $(CFLAGS) $(MAINFLAGS) $(INCLUDE) $<

graded-writer: $(OBJECTS)
	$(CC) $(LDFLAGS) -o $@ $^

all: graded-writer

clean:
	rm -f graded-writer

install: all
	mkdir -p $(DESTDIR)/$(BINDIR)  $(DESTDIR)/$(PCDIR)
